const Koa = require('koa')
const serve = require('koa-static')
const {historyApiFallback} = require('koa2-connect-history-api-fallback')
const proxy = require('koa2-proxy-middleware')

const app = new Koa()

app.use(proxy({
    targets:{
        '/prod-api/(.*)':{
            target:'http://ihrm-java.itheima.net',
            changeOrigin:true,
            pathRewrite:{
                '/prod-api':'/api'
            }
        }
    }
}))

app.use(historyApiFallback())

app.use(serve(__dirname+'/web'))

app.listen(3333,()=>{
    console.log('服务器开启成功');
    console.log('http://localhost:3333');
})